# Maintainer: qme5400 <qme5400@gmail.com>

_realname=enet
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.13
pkgrel=1
pkgdesc="Reliable UDP networking library (mingw-w64)"
url="http://enet.bespin.org/"
arch=('any')
license=('custom')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('staticlibs' 'strip')
source=("http://enet.bespin.org/download/${_realname}-${pkgver}.tar.gz"
        001-no-undefined.patch
        002-win-libs.patch)
sha256sums=('e36072021faa28731b08c15b1c3b5b91b911baf5f6abcc7fe4a6d425abada35c'
            '804393e6274187861c5837fba57451d45fa1c12b815e1b3ff8e5d3830082b254'
            '2a9129b4cc9f53917382c48d0f4bc83c54d9d0f43e30fd71c8d4d60d3f351a7e')

prepare() {
  cd "${srcdir}/enet-${pkgver}"
  patch -p1 -i ${srcdir}/001-no-undefined.patch
  patch -p1 -i ${srcdir}/002-win-libs.patch

  autoreconf -fiv
}

build() {
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  ../${_realname}-${pkgver}/configure \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST} \
      --prefix=${MINGW_PREFIX}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
